﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KD.Sms.UI_Operate
{
    public partial class frmUploadWl : Form
    {
        public frmUploadWl()
        {
            InitializeComponent();
        }

        private void tools_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
        {
            if (e.Tool.Key == "Query")
            {
                DoBind();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmUploadWl_Load(object sender, EventArgs e)
        {

        }


        /// <summary>
        /// 
        /// </summary>
        public void DoBind()
        {
            gridMain.DataSource = DAL.SqlLite.Main.Instance.DoQuerySamplingsForUpdateWl(txtCarNum.Text.Trim());
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridMain_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (gridMain.Columns[e.ColumnIndex].Name == "CYWC")
            {
                try
                {
                    DAL.Sqlserver.Interface.Instance.DoUpdateSamplingEndToWl(gridMain.Rows[e.RowIndex].Cells["CardNo"].Value.ToString());
                    UI.MsgBox.Show(UI.MsgType.Information, "操作成功");

                    DAL.SqlLite.Main.Instance.LogWrite(SysLogType.Login, string.Format("强制{0}采样完成", gridMain.Rows[e.RowIndex].Cells["Car_No"].Value.ToString())); 
                }
                catch
                {
                    UI.MsgBox.Show(UI.MsgType.Error, "操作失败！请首先排查与物料系统之间网络是否通畅！");
                }
            }
        }

        private void gridMain_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
